-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove all getters #36
Conversation
One general remark: I prefer getters for fields which are set once (internally) and then shouldn't be possible to modify its value from outside (hence the "getter" and a private/unexported field). But this is more a question of style I guess.
I think I know what you mean but in general this isn't always the case: In golang it isn't uncommon to have getters but they just aren't prefixed with get* (https://golang.org/doc/effective_go.html#Getters). |
I think using getters for those fields have not much advantages compare to exporting them. If I use getters, I have to keep adding them whenever there are some new fields in struct, and I ain't sure it's good thing. |
I agree that issues can arise from forgetting to add getters whenever you add a new struct field, but I don't see how it's a bad thing to have to add these getters. I agree with @liamsi and I think using getters where needed more properly expresses the access we want outside modules to have to certain fields. Exporting gives write-access to those fields, too, no? I'd rather take a more conservative approach and export only those fields that really need to be writable from outside. |
Yes, it does. I also agree with @liamsi , that's exactly why I use those getters at first. |
You are right, the getters do not prevent changing the underlying slices. I still think that those getters provided a nicer API, but now that you mentioned it, I agree that the getters seem to be even more misleading (as they provide a false sense of security and people coming from other languages might think they are not changing the underlying slices while in fact they are). You convinced me and I'm OK with removing all those getters! |
Thanks @c633 and @liamsi for the explanations!
I see, it's a lot clearer to me now.
Yup, that's me. Coming from Java where getters are everywhere, I assumed they had the same semantics in Go. |
LGTM. |
Golang code should not use getters and setters rather than struct fields.This pull removes all getters fromSTR
,AuthenticationPath
,TemporaryBinding
andDefaultPolicies
struct./cc @arlolra @masomel @liamsi